﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace FeedAntGame.Sprite
{
    class PointerSprite : BaseSprite
    {
        int reVisibleTime = 1200;

        public int ReVisibleTime
        {
            get { return reVisibleTime; }
            set
            { 
                reVisibleTime = value*2;
                curReVisibleTime = reVisibleTime;
            }
        }
        int curReVisibleTime = 1200;

        public PointerSprite(Texture2D textureImage, Vector2 position, Point frameSize, float scale, int reVisibleTime)
            : base(textureImage, position, frameSize, 0, Point.Zero,
            new Point(1,1), Vector2.Zero, null, 0, scale)
        {
            this.ReVisibleTime = reVisibleTime;
        }

        public override Vector2 Direction
        {
            get { return speed; }
        }

        public override void Update(GameTime gameTime, Rectangle clientBounds)
        {
            Position += Direction;
            curReVisibleTime -= gameTime.ElapsedGameTime.Milliseconds;
            if (curReVisibleTime <= reVisibleTime/2)
            {
                this.visible = false;
            }
            if(curReVisibleTime <= 0)
            {
                curReVisibleTime = reVisibleTime;
                this.visible = true;
            }
            
            base.Update(gameTime, clientBounds);
        }
    }
}
